package jdk8;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.junit.Test;

public class LambdaTest {



    @Test
    public void testLocalVariable() {
        int i = 7;
        Thread t = new Thread(() -> {
            System.out.println(i);
        });
        t.run();
    }
    int j = 6;
    User userA = new User("A");
    User userB = new User("B");
    @Test
    public void testInstanceVariable() {
        Thread t = new Thread(() -> {
            System.out.println(j);
        });
        j = 7;
        t.run();

        Thread t2 = new Thread(() -> {
            System.out.println(userA.getName());
        });
        userA = userB;
        userA.setName("new-A");
        t2.run();

        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(userA.getName());
            }
        });
        t3.run();
    }

}
@Data
@AllArgsConstructor
class User{
    private String name;
}
